package ihm.dialog;

import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

public class WaitDialog extends Thread {

	private String title = "";
	private String message = "";
	
	private Component parent;
	
	private JOptionPane optionPane;
	private JDialog dialog;

	public WaitDialog(Component parent, String title, String message) {
		this.title = title;
		this.message = message;
		this.parent = parent;
	}
	
	@Override
	public void run() {
		optionPane = new JOptionPane(message,
				JOptionPane.INFORMATION_MESSAGE,
				JOptionPane.DEFAULT_OPTION,
				null, new Object[]{}, null);

		dialog = new JDialog();
		dialog.setTitle(title);
		//dialog.setModal(true);
		dialog.setContentPane(optionPane);
		dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		dialog.setAlwaysOnTop(true);
		dialog.setLocationRelativeTo(parent);
		dialog.pack();
		dialog.setVisible(true);
	}
	
	public void dispose() {
		dialog.dispose();
	}

}
